package com.zoe.thread.th06_集合不安全问题;

import cn.hutool.core.lang.UUID;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @Author Zoe
 * @Date: 2021/05/04
 * @Description
 */
public class HashMapDemo {
    public static void main(String[] args) {
        hashMapSafe();
    }

    private static void hashMapSafe() {
        Map<String,Object> hashMap = new ConcurrentHashMap<>();
        for (int i = 0; i < 30; i++) {
            new Thread(() -> {
                hashMap.put(UUID.fastUUID().toString(), "年后");
                System.out.println(hashMap);
            }, i+"").start();
        }
    }
}
